#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

class Solution{
    public:
    int ans1(int x){
        int l = 0, r = x;
        int ans = -1;
        while(l <= r){
            int mid = (l + r) / 2;
            if((long long)mid * mid < x){
                ans = mid;
                l = mid + 1;
            }else if((long long)mid * mid > x){
                r = mid - 1;
            }else{
                ans = mid;
                break;
            }
        }
        return ans;
    }
};

void test1(){
    Solution s;
    int x = 4;

    int ret = s.ans1(x);
    cout << ret << endl;
}

void test2(){
    Solution s;
    int x = 8;

    int ret = s.ans1(x);
    cout << ret << endl;
}

void test3(){
    Solution s;
    int x = 0;

    int ret = s.ans1(x);
    cout << ret << endl;
}

int main(void){
    test1();
    test2();
    test3();

    return 0;
}